//jshint ignore:start
// const gradeId = localStorage.getItem("gradeId");
const gradeId = window.gradeId;
const startPage = localStorage.getItem("startPage");
const readingValue = gradeId === "81" && startPage === "0"?0:1;
export async function getPage(index){
	const { data,page } = await (await fetch(new URL(`../jsonData/pdf/pdf_${ Number(index) + 1 }.json`,import.meta.url))).json();
	return {
		id:data.at(0)?.id,
		url:data.at(0)?.url,
		width:data.at(0)?.width,
		height:data.at(0)?.height,
		coordinate:data.at(0)?.coordinate?.map(({ audio,audio_url,translation,points })=>({ audio,audio_url,translation,points })),
		total:page.total_page,
		current:page.current_page,
	};
}
export async function getCatalog(gradeId){
	const res = await (await fetch(new URL(`../jsonData/catalog.json`,import.meta.url))).json();
	return res;
}
export async function getReading(gradeId,index){
	const { data } = await (await fetch(new URL(`../jsonData/read/textbook_read_${ Number(index) + readingValue }.json`,import.meta.url))).json();
	return data;
}
